package com.example.dqnm.controller;

import com.example.dqnm.pojo.Orders;
import com.example.dqnm.pojo.ajaxResult;
import com.example.dqnm.service.OrderService;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RequiredArgsConstructor
@RestController
@RequestMapping("/order")
public class orderController {
    @Autowired
    private OrderService orderService;
    @PostMapping("/addOrders")
    public ajaxResult<Boolean> insertOrders(@RequestBody Orders orders) {
        Boolean flag = orderService.insertOrders(orders);
        return new ajaxResult<>(flag);
    }

    @GetMapping("/findAllOrders")
    public ajaxResult<List<Orders>> findAllOrdersByUserId(Integer id, String orderStatus) {
        List<Orders> ordersList = orderService.findAllOrdersByUserId(id,orderStatus);
        return new ajaxResult<>(ordersList);
    }
}
